package com.show.mytest;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class Test02_BufferedReader_Writer {
    public static void main(String[] args) throws Exception {
        // 创建一个缓冲字符输入流
        BufferedReader br = new BufferedReader(new FileReader("F:/配置.txt"));
        // 创建一个缓冲字符输出流
        BufferedWriter bw = new BufferedWriter(new FileWriter("F:/配置2.txt"));
        try (br;bw) {
            // 创建字符串接收读取的字符串
            String line = null;
            // 当接收的字符串不为空时,接收一行
            while ((line = br.readLine()) != null){
                // 使用bw写出字符串
                bw.write(line);
                // 刷新缓冲流
                bw.flush();
            }
        } catch (Exception e){
            e.printStackTrace();
        } finally {
            if (bw != null){
                bw.close();
            }
            if (br != null){
                br.close();
            }
        }
    }
}
